<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="/view/main/stylesheet.jsp"%>
<link rel="stylesheet" type="text/css"
	href="${baseurl}/styles/frameword/css/list.css" />
<script src="${baseurl}/styles/frameword/js/list.js"
	type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var statejson = <wb:html wbCode="pro-video-state" type="json" name="" />
	var typejson = <wb:html wbCode="pro-video-advertising-type" type="json" name="" />
	var tableId = "table1";
	$(function() {
		var url = "/pro-video-info/";
		var columns = [
				{
					field : 'videoName',
					title : '视频名称'
				},
				{
					field : 'userName',
					title : '归属用户'
				},
				{
					field : 'startDate',
					title : '开始日期',
					formatter : function(value, row, index) {
						return format(new Date(value), 'yyyy-MM-dd');
					}
				},
				{
					field : 'stopDate',
					title : '结束日期',
					formatter : function(value, row, index) {
						return format(new Date(value), 'yyyy-MM-dd');
					}
				},
				{
					field : 'state',
					title : '发布状态',
					formatter : function(value, row, index) {
						return statejson[value];
					}
				},
				{
					field : 'redEnvelopTotal',
					title : '红包总额',
					formatter : function(value, row, index) {
						return (value / 100).toFixed(2);
					}
				},
				{
					field : 'driverPlayNum',
					title : '播放终端数量'
				},
				{
					field : 'driverNum',
					title : '终端数量'
				},
				{
					field : 'type',
					title : '广告类型',
					formatter : function(value, row, index) {
						return typejson[value];
					}
				},
				{
					field : 'operate',
					title : '操作',
					align : 'center',
					events : {
						'click .BtnOfDetails' : function(e, value, row, index) {
							var url2 = "/pro-video-reward/";
							var index = layer.open({
								type : 2,
								title : '详情',
								offset : '100px',
								shadeClose : true,
								shade : 0.8,
								area : [ '650px', '480px' ],
								content : baseUrl + url2 + row.primaryKey
							});
							layer.full(index);
						},
						'click .BtnOfUpdate' : function(e, value, row, index) {
							var index = layer.open({
								type : 2,
								title : '编辑',
								offset : '100px',
								shadeClose : true,
								shade : 0.8,
								area : [ '650px', '480px' ],
								end : function() {
									$("#" + tableId).bootstrapTable('refresh');
								},
								content : baseUrl + url + row.primaryKey
										+ '/update'
							});
							layer.full(index);
						},
						'click .BtnOfDel' : function(e, value, row, index) {
							layer.confirm('确定删除?', {
								btn : [ '删除', '取消' ]
							}, function() {
								$.get(baseUrl + url + row.primaryKey + '/del',
										function(result) {
											if (result) {
												$("#" + tableId)
														.bootstrapTable(
																'refresh');
												layer.msg('删除成功', {
													icon : 1,
													time : 1000
												});
											}
										}, "json");
							}, function() {
								layer.closeAll('dialog');
							});
						}
					},
					formatter : function(value, row, index) {
						return [
								'<span class="BtnOfDetails pointer glyphicon glyphicon-list" style="margin-right:15px;">终端列表</span>',//
								'<span class="BtnOfUpdate pointer glyphicon glyphicon-edit" style="margin-right:15px;">编辑</span>',//
								'<span class="BtnOfDel pointer glyphicon glyphicon-remove" style="margin-right:15px;">删除</span>', ]
								.join('');
					},
				} ];
		initListDefault(url, columns)
	})
</script>
</head>
<body class="container-fluid">
	<form class="bs-example bs-example-form" role="form" id="form1">
		<table class="table noline">
			<tbody>
				<tr>
					<td>
						<div class="input-group">
							<span class="input-group-addon explain">归属用户</span> <input
								type="text" name="userId" class="form-control">
						</div>
					</td>
					<td>
						<div class="input-group">
							<span class="input-group-addon explain">区域范围</span>
							<wb:html wbCode="pro-city" name="areaScope" nullvalue="true"
								type="select" />
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="input-group">
							<span class="input-group-addon explain">发布状态</span>
							<wb:html wbCode="pro-video-state" name="state" nullvalue="true"
								type="select" />
						</div>
					</td>

					<td>
						<div class="input-group">
							<span class="input-group-addon explain">视频名称</span> <input
								type="text" name="videoName" class="form-control">
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<div class="input-group">
							<span class="input-group-addon explain">视频类型</span> 
							<wb:html wbCode="pro-video-advertising-type" name="type" nullvalue="true"
								type="select" />
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="2" style="text-align: right;">
						<div class="btn-group">
				    	<c:if test="${belongCity=='全国'}">
							<button type="button" class="btn btn-success" id="add-button"
								data-url="/pro-video-info/add">
								<i class="glyphicon glyphicon-plus"></i> 添加
							</button>
							<button type="button" class="btn btn-info" id="search-button">
								<i class="glyphicon glyphicon-search"></i> 搜索
							</button>
						</c:if>
				    	<c:if test="${belongCity!='全国'}">
							<button type="button" class="btn btn-info" id="search-button">
								<i class="glyphicon glyphicon-search"></i> 搜索
							</button>
						</c:if>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
	<table id="table1">
	</table>
</body>

</html>